import json

from ronglian_sms_sdk import SmsSDK


class SmsUtil:
    __instance = None

    def __new__(cls, *args, **kwargs):
        if not cls.__instance:
            cls.__instance = super().__new__(cls, *args, **kwargs)
            cls.smsSdk = SmsSDK(accId='8aaf07087dc23905017dc781c48701e4',
                                accToken='46b2b281e860458b90071aea618a1756',
                                appId='8aaf07087dc23905017dc78423a801ee')
        return cls.__instance

    def send_message(self, mobile='18325495726', tid='1', code='1234'):
        sendback = self.smsSdk.sendMessage(tid=tid, mobile=mobile, datas=(code, 5))

        sendback = json.loads(sendback)
        # 'statusCode':'000000'
        if sendback.get('statusCode') == '000000':
            print('发送成功')
        else:
            print("发送失败")





